package com.itboye.shop.responsitory;

import com.google.gson.reflect.TypeToken;
import com.itboye.shop.bean.BankCodeBean;
import com.itboye.shop.bean.GoPayBean;
import com.itboye.shop.bean.JiaoYiJiLuBean;
import com.itboye.shop.bean.MoneyShengyuBean;
import com.itboye.shop.interfaces.YuEInterfaces;
import com.itboye.shop.net.BaseErrorListener;
import com.itboye.shop.net.BaseNetRepository;
import com.itboye.shop.net.BaseSuccessReqListener;
import com.itboye.shop.net.ByJsonRequest;
import com.itboye.shop.net.ICompleteListener;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 余额
 */
public class YuEPresponsitory extends BaseNetRepository implements YuEInterfaces<String> {
    public static final String APIKEY = "100";

    public static final String Pwass = "By_Wallet_setSecret";//设置密码或者重置
    public static final String PWD = "By_Wallet_checkSecret";//支付密码验证
    public static final String Yuen = "By_Wallet_detail";//余额
    public static final String dingdan = "By_Wallet_his";//余额变动记录   我的订单
    public static final String chongzhi = "By_Wallet_order";//充值
    public static final String ZhanghaoList = "By_Wallet_bindList";//提现账号列表
    public static final String deleteZhangHao = "By_Wallet_bindDel";//删除绑定的账号

    public static final String BandingType = "By_Wallet_bindType";//支持账号类型
    public static final String Bhang = "By_Wallet_bind";//绑定提现账户
    public static final String Tixian = "By_Wallet_apply";//提现申请

    public YuEPresponsitory(ICompleteListener iCompleteListener) {
        super(iCompleteListener);
    }

    /**
     * 设置支付密码
     *
     * @param uid
     * @param old
     * @param news
     */
    @Override
    public void OnSetUpZhiFuPass(String uid, String old, String news) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = APIKEY;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("old", old);
        map.put("new", news);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(Pwass, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    /**
     * 支付密码验证
     *
     * @param uid
     * @param secret
     */
    @Override
    public void onZhiFuPassYanZheng(String uid, String secret) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = APIKEY;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("secret", secret);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(PWD, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onMoney(String uid) {
        Type Type = new TypeToken<MoneyShengyuBean>() {
        }.getType();
        String apiVer = APIKEY;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        (new ByJsonRequest.Builder<MoneyShengyuBean>())
                .setTypeVerParamsAndReturnClass(Yuen, apiVer, map, Type)
                .requestListener(
                        new BaseSuccessReqListener<MoneyShengyuBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    /**
     * 我的账单
     *
     * @param uid
     * @param current_page
     * @param per_page
     */
    @Override
    public void onZhangDan(String uid, String current_page, String per_page) {
        Type type = new TypeToken<JiaoYiJiLuBean>() {
        }.getType();
        String apiVer = APIKEY;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("current_page", current_page);
        map.put("per_page", per_page);

        (new ByJsonRequest.Builder<JiaoYiJiLuBean>())
                .setTypeVerParamsAndReturnClass(dingdan, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<JiaoYiJiLuBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    /**
     * 充值（获取充值信息）
     *
     * @param uid
     * @param money 充值金额,分,1+
     */
    @Override
    public void chongZhi(String uid, String money) {
        Type type = new TypeToken<GoPayBean>() {
        }.getType();
        String apiVer = APIKEY;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("money", money);

        (new ByJsonRequest.Builder<GoPayBean>())
                .setTypeVerParamsAndReturnClass(chongzhi, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<GoPayBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    /**
     * 提现账号列表
     *
     * @param uid
     */
    @Override
    public void onZhangHaoList(String uid) {
        Type Type = new TypeToken<List<BankCodeBean>>() {
        }.getType();
        String apiVer = APIKEY;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);

        (new ByJsonRequest.Builder<List<BankCodeBean>>())
                .setTypeVerParamsAndReturnClass(ZhanghaoList, apiVer, map, Type)
                .requestListener(
                        new BaseSuccessReqListener<List<BankCodeBean>>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    /**
     * 删除绑定的账号
     *
     * @param uid
     * @param id
     */
    @Override
    public void deleteZhangHao(String uid, String id) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = APIKEY;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id", id);

        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(deleteZhangHao, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onBangDinType() {
        Type Type = new TypeToken<List<BankCodeBean>>() {
        }.getType();
        String apiVer = APIKEY;
        Map<String, Object> map = new HashMap<>();

        (new ByJsonRequest.Builder<List<BankCodeBean>>())
                .setTypeVerParamsAndReturnClass(BandingType, apiVer, map, Type)
                .requestListener(
                        new BaseSuccessReqListener<List<BankCodeBean>>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    /**
     * 绑定提现账户
     * @param uid
     * @param account
     * @param account_type
     * @param open_bank
     */
    @Override
    public void onByWalletBind(String uid, String account, String account_type,String open_bank) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = APIKEY;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("account", account);
        map.put("account_type", account_type);
        map.put("open_bank", open_bank);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(Bhang,apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    /**
     * 提现申请
     * @param uid
     * @param account_id
     * @param money
     */
    @Override
    public void onMoneySys(String uid, String account_id, String money) {
        Type Type = new TypeToken<String>() {
        }.getType();
        String apiVer = APIKEY;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("account_id", account_id);
        map.put("money", money);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(Tixian, apiVer, map, Type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }
}
